home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / basic / qbfaqr01.zip / KEYWAIT.BAS < prev    next >
BASIC Source File  |  1992-08-09  |  1KB  |  45 lines

  1. DEFINT A-Z
  2.  
  3. '$INCLUDE: 'QB.BI'
  4.  
  5. DECLARE FUNCTION KeyInBuf ()
  6.  
  7. '***********************************************************************
  8. '* FUNCTION KeyInBuf
  9. '*
  10. '* PURPOSE
  11. '*    Uses BIOS ISR 16H, Service 01H (Report Whether Character Ready)
  12. '*    to return a keypress if one is waiting in the keyboard buffer.
  13. '*    If the key pressed is a normal key, this function will return the
  14. '*    ASCII value for that key; if the key pressed is an extended key
  15. '*    (such as F1) this function will return the ascii value for that
  16. '*    key negated.  This function does not remove the key from the
  17. '*    keyboard buffer.
  18. '*
  19. '* EXTERNAL ROUTINE(S)
  20. '*    QBX.LIB:
  21. '*    --------
  22. '*    SUB Interrupt (IntNum, InRegs AS RegType, OutRegs AS RegType)
  23. '***********************************************************************
  24. FUNCTION KeyInBuf STATIC
  25.    InRegs.ax = &H100
  26.    Interrupt &H16, InRegs, OutRegs
  27.  
  28.    IF ((OutRegs.flags AND 64) \ 64) = 0 THEN '0 if a key is pending
  29.       'If the key pressed is a normal key, alReg holds the ASCII code for
  30.       'that key and ahReg holds the standard PC-keyboard scan code;
  31.       'otherwise, (a special key was pressed such as F1) alReg holds 0
  32.       'and ahReg holds the character ID.
  33.       alReg = OutRegs.ax AND &HFF
  34.       ahReg = OutRegs.ax \ &HFF
  35.  
  36.       IF alReg THEN
  37.          KeyInBuf = alReg
  38.       ELSE
  39.          KeyInBuf = -ahReg
  40.       END IF
  41.    ELSE
  42.       KeyInBuf = 0
  43.    END IF
  44. END FUNCTION
  45.